﻿<div class="tabbable">
    <ul class="nav nav-tabs" id="myTab">
        <li class="active">
            <a data-toggle="tab" href="#tab1">题库</a>
        </li>
        <li class="tab-red">
            <a data-toggle="tab" href="#tab2">增加</a>
        </li>
    </ul>

    <div class="tab-content">
        <div id="tab1" class="tab-pane active table-responsive">
            <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                <thead>
                    <tr>
                        <th class="text-center col-lg-1 col-md-2 col-xs-2">
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" class="group-checkable" data-set="#flip .checkboxes">
                                    <span class="text">全选</span>
                                </label>
                            </div>
                        </th>
                        <th class="text-center col-lg-1 col-md-2 col-xs-2">难度</th>
                        <th class="text-center col-lg-1 col-md-2 col-xs-4">题目描述</th>
                        <th class="text-center col-lg-1 col-md-4 col-xs-2">素材</th>
                        <th class="text-center col-lg-2 col-md-2 col-xs-2">操作</th>
                    </tr>
                </thead>
                <tbody>
                	<?php foreach( $questions as $q ): ?>
                    <tr>
                        <td class="text-center">
                            <div class="checkbox">
                            	<label>
                            		<input type="checkbox" class="checkboxes" name="id[]" value="<?=$q['id'];?>">
                            		<span class="text"><?=$q['id'];?></span>
                            	</label>
                            </div>
                        </td>
                        <td class="text-center">
                        	<?php switch( $q['level'] ){
                        		case 1:
                        	?>
                        	<span class="badge badge-square badge-success">1</span>
                        	<?php break; case 2: ?>
                        	<span class="badge badge-square badge-azure">2</span>
                        	<?php break; case 3: ?>
                        	<span class="badge badge-square badge-warning">3</span>
                        	<?php break; case 4: ?>
                        	<span class="badge badge-square badge-danger">4</span>
                        	<?php break; } ?>
                        </td>
                        <td><?=$q['content'];?></td>
                        <td class="text-center">
                        	<?php if( $q[ 'attach' ] ): ?>
                        		<a href="<?=base_url().$setting['q_dir'].$q['id'].'/'.$q['attach'] ;?>" target="_blank" class="btn btn-primary btn-xs"><i class="fa fa-cloud-download"></i> 下载</a>
                        	<?php else: ?>
                        		无
                        	<?php endif; ?>
                        </td>
                        <td class="text-center ">
                        	<button class="btn btn-success btn-xs edit" onclick="show_modal( 'modal', '<?=site_url('question/edit_question') . '/' . $q['id'];?>')"><i class="fa fa-pencil"></i> 修改</button>
							<button class="btn btn-danger btn-xs delete" onclick="bb_confirm( '确定要删除【id：<?=$q['id'];?>】的题目吗？', '<?=site_url('question/del_question') . '/' . $q['id'];?>')"><i class="fa fa-trash-o"></i> 删除</button>
                        </td>
                    </tr>
                  	<?php endforeach; ?>
                </tbody>
            </table>
        </div>

        <div id="tab2" class="tab-pane">
			<form class="form" id="add_question" enctype="multipart/form-data" action="<?=site_url('question/add_question');?>" method="post">
				
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-lg-1 col-md-1 col-xs-3">题目难度</label>
					
					<?php for( $i=1; $i <= $setting[ 'level' ]; $i++ ):?>
					<div class="col-lg-1 col-sm-1 col-xs-1">
						<div class="radio">
							<label>
								<input type="radio" name="level" value="<?=$i;?>" <?php if($i==1) echo 'checked';?>>
								<span class="text"><?=$i;?></span>
							</label>
						</div>
					</div>
					<?php endfor; ?>
					
				</div>
				<div class="form-group clearfix form-bordered">
	                <label class="control-label col-lg-1 col-md-1 col-xs-3">题目描述</label>
	                <div class="col-md-11">
		                <textarea id="content" name="content"></textarea>
	                </div>
                </div>
				<div class="form-group clearfix form-bordered">
					<label class="control-label col-lg-1 col-md-1 col-xs-3">素材附件</label>
					<div class="col-md-11">
						<div class="form-group">
							<input type="file" name="attach">
						</div>
					</div>
				</div>
				<div class="form-group text-right clearfix">
					<button class="btn btn-success" type="submit"><i class="fa fa-plus"></i>添加</button>
					<button type="reset" class="btn btn-default" id="cancel">取消</button>
				</div>

			</form>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
<!--Page Related styles-->
<link href="<?=$tpl_dir;?>assets/css/dataTables.bootstrap.css" rel="stylesheet" />
<!--Page Related Scripts-->
<script src="<?=$tpl_dir;?>assets/js/datatable/jquery.dataTables.min.js"></script>
<script src="<?=$tpl_dir;?>assets/js/datatable/ZeroClipboard.js"></script>
<script src="<?=$tpl_dir;?>assets/js/datatable/dataTables.bootstrap.min.js"></script>
<script src="<?=$tpl_dir;?>assets/js/datatable/datatables-init.js"></script>
<!--Ueditor-->
<script src="<?=$tpl_dir?>assets/ueditor/ueditor.config.js"></script>
<script src="<?=$tpl_dir?>assets/ueditor/ueditor.all.js"></script>
<script>
InitiateSimpleDataTable.init();

window.UEDITOR_HOME_URL = "<?=$tpl_dir?>assets/ueditor/";
var q_content = UE.getEditor('content');
q_content.ready(function() {
	//设置编辑器的内容
	q_content.setContent('');
});

</script>